<?php
require_once('lib/menu.php');
require_once('lib/content.php');

?>
<script src="pages_admin/menus/_menus.js" type="text/javascript"></script>
<div id="menus_suppression">
<h3>Suppression de menus</h3>
<div class="ajax"></div>
<?php
$menus_blocs = menu_get_unlocked();
if ($row = mysql_fetch_assoc($menus_blocs)) {
	?>
	<table class="dataTable">
		<thead>
		<tr>
			<th>Nom</th>
			<th>Type</th>
			<th>Utilisé</th>
			<th>Contenu associé</th>
			<th>Bloc lié</th>
			<th>Action</th>
		</tr>
		</thead>
		<tbody>
	<?php
	do {
		$is_menu = $row['idMenu'];
		$type = $is_menu ? 'Menu' : 'Bloc';
		$name = $is_menu ? $row['name'] : '<span style="background:url(\'images/icons/'.$row['image'].'\') no-repeat; padding-left:25px;">'.$row['name'].'</span>';
		$menu = $is_menu ? menu_get_name($row['idMenu']) : '-';
		$used = $row['used'] ? 'Oui' : 'Non';
		$linked_content = $row['used'] && $is_menu ? content_get_by_menu($row['id']) : '-';

		echo '
		<tr id="ligne'.$row['id'].'">
			<td><strong>'.$name.'</strong></td>
			<td>'.$type.'</td>
			<td>'.$used.'</td>
			<td>'.$linked_content['id'].'</td>
			<td>'.$menu.'</td>
			<td>
				<span>
					<a href="javascript:void(0);" class="js-ask-validation" title="Supprimer ce menu">
						<img src="images/icons/delete.png" alt="Supprimer" />
					</a>
					<div class="hidden decalhaut">
						Supprimer ?<br />
						<a href="javascript:void(0);" class="js-del-menu b-oui" id="delmenu_'.$row['id'].'_'.$row['idMenu'].'"></a>
						<a href="javascript:void(0);" class="js-hide b-non"></a>
					</div>
				</span>
			</td>
		</tr>';
	} while ($row = mysql_fetch_assoc($menus_blocs));
	?>
		</tbody>
	</table>
<?php
}
else {
	?>
	<p class="info">
		Il n'y a aucun menu que vous pouvez supprimer pour le moment
	</p>
	<?php
} ?>
</div>
